import { NEl } from 'naive-ui'
import QueryForm from './query-form'
import BasicTable from './basic-table'
import './style/index.less'
import { proTableProps } from './typing.ts'
import { useProTableProvider } from '@/components/pro-table/context.ts'

/**
 * @ClassName: index
 * @Description: // 入口文件
 * @Author: Ellwood
 * @CreateDate: 2024/2/23 - 7:46
 * @Version: V1.0.0
 */
const proTable = defineComponent({
  name: 'ProTable',
  props: {
    ...proTableProps,
  },
  setup(props, { slots }) {
    useProTableProvider(props)
    return () => {
      const basicTableSlots = {
        empty: slots.empty,
        loading: slots.loading,
      }

      return (
        <NEl tag="div" class="pro-table">
          <QueryForm />
          <BasicTable {...props} v-slots={basicTableSlots} />
        </NEl>
      )
    }
  },
})

export default proTable
